<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: null,
    name: "",
    rank: 0
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="名称" prop="name">
      <el-input
        v-model="newFormInline.name"
        clearable
        placeholder="请输入名称"
      />
    </el-form-item>

    <el-form-item label="排序" prop="rank">
      <el-input-number
        v-model="newFormInline.rank"
        :min="0"
        :max="9999"
        controls-position="right"
      />
    </el-form-item>

    <!--    <el-form-item label="附件" prop="fileList">-->
    <!--      <ReUpload-->
    <!--        ref="uploadRef"-->
    <!--        v-model:fileList="newFormInline.fileList"-->
    <!--        :businessId="newFormInline.id"-->
    <!--        :limit="5"-->
    <!--        tableName="categories"-->
    <!--      />-->
    <!--    </el-form-item>-->
  </el-form>
</template>
